package fm.dongman.modellib.source

import fm.dongman.animefm.contractlib.BaseDataSource
import fm.dongman.animefm.contractlib.contract.VideoPlayContract
import fm.dongman.animefm.contractlib.model.VideoSideTagModel
import fm.dongman.modellib.RemoteHelper
import fm.dongman.modellib.StaticArea.StaticUrl
import fm.dongman.modellib.remote.RemoteOperationHelper

/**
 * 视频播放数据获取
 * Created by shize on 2017/12/5.
 */
class VideoPlayRepository : VideoPlayContract.IVideoPlayDataSource {

    override fun getData(callback: BaseDataSource.LoadSourceCallback<List<VideoSideTagModel>>) {
        val json = RemoteHelper.instance.parseGetUrl(StaticUrl.VIDEO_TAG)
        if (json == null){
            callback.onDataLoadFiled()
            return
        }
        callback.onDataLoaded(RemoteOperationHelper.getOperationHelper().downVideoTag(json))
    }

    override fun saveData(dataModel: List<VideoSideTagModel>) {
    }

    override fun offLine() {
    }

    override fun refreshData() {
    }

    companion object {
        private var INSTANCE: VideoPlayRepository? = null

        fun getInstance(): VideoPlayRepository {
            if (INSTANCE == null) {
                INSTANCE = VideoPlayRepository()
            }
            return INSTANCE!!
        }
    }
}